package com.foucus.myfouces.MVP.View.views.Fragment;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.foucus.myfouces.Base.BaseFragment;
import com.foucus.myfouces.MVP.Model.SquareVideoResp;
import com.foucus.myfouces.MVP.Presenler.IPresenler.ISquareVideoP;
import com.foucus.myfouces.MVP.Presenler.Presenler_class.SquareVideoP;
import com.foucus.myfouces.MVP.View.IView.ISelectRecommentFG;
import com.foucus.myfouces.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yf-06 on 2017/7/13.
 */

public class SelectRecommentFragment extends BaseFragment implements View.OnClickListener, ISelectRecommentFG {
    private View rootView;
    private Activity mActivity;
    private String typename;

    private ISquareVideoP iSquareVideoP;
    private List<SquareVideoResp.ResultBean.DataBean> SquareVideoList;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (rootView == null) {
            rootView = inflater.inflate(R.layout.select_recomment_fg, container, false);
        }
        ViewGroup parent = (ViewGroup) rootView.getParent();
        if (parent != null) {
            parent.removeView(rootView);
        }

        return rootView;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        mActivity = getActivity();
        init();

    }

    private void init() {
        SquareVideoList = new ArrayList<>();
    }

    private void initData() {
        iSquareVideoP = new SquareVideoP(mActivity, this);
//        iSquareVideoP.getSquareVideo("0");
    }

    @Override
    public void onResume() {
        super.onResume();
        typename = getArguments().getString("type");
        Log.e("ssss", "typename==>" + typename);
        initData();
    }


    @Override
    public void onSquareVideoCompleted(List<SquareVideoResp.ResultBean.DataBean> dataBeanList) {
        for (int i = 0; i < dataBeanList.size(); i++) {
            if (dataBeanList.get(i).getName().equals(typename)) {
                SquareVideoList.add(dataBeanList.get(i));
                for (int j = 0; j < SquareVideoList.size(); j++) {
                    Log.e("ssss", "SquareVideoList==>" + SquareVideoList.get(j).getName());
                }
            }
        }
    }

    @Override
    public void onSquareVideoError() {

    }

    @Override
    public void onClick(View v) {

    }
}
